home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / self / contrib.lha / contrib / simulator / README < prev    next >
Encoding:
Text File  |  1993-06-25  |  7.8 KB  |  180 lines

  1. These files are part of a simple digital circuit simulator. It was written
  2. for Self 1.0 and adapted to run in Self 1.1 ( or was it 1.1 and 1.2 
  3. respectively? ). It should be easily ported to 2.0 or later simply by
  4. changing the _DefineSlots: in all of the files. I don't think any or
  5. features are version dependent. The "askSim" method uses _ReadInto:Count:
  6. which might have to be rewritten.
  7.  
  8. The program is not at all elegant and users should be warned that sim.self
  9. creates "global" parent slots in "prototypes simulation": simRoot** and
  10. fsmRoot***. This is so the Self command line can find the components and
  11. pins defined in the circuit being simulated. There is a graphical display
  12. of waveforms, but it writes directly to the screen and is plain horrible.
  13.  
  14. -----------------------------------
  15. The files are:
  16.  
  17.    Lines   Name
  18.       23 allSim.self
  19.       12 batch1.self
  20.        5 batch2.self
  21.       12 batch3.self
  22.      126 examples.self
  23.      265 levels.self
  24.      361 lib.self
  25.      528 sim.self
  26.     1332 total
  27.  
  28. allSim.self reads in the other files.
  29.  
  30. The batchX.self can save some typing when trying out some examples.
  31.  
  32. sim.self is the "main" program, with all kinds of objects.
  33.  
  34. levels.self defines 27 logic "levels" used to model CMOS circuits.
  35.  
  36. lib.self sets up the names space for defining components and declares
  37. the most basic CMOS transistors ( not really bidirectional! ) and
  38. simple logic gates.
  39.  
  40. examples.self has some circuits to test several of the simulator's
  41. features.
  42. -------------------------------------
  43. The key object is the component which must have these slots:
  44.  
  45.   parent* = traits simulation component. "where we get all our smarts"
  46.   sim**.                          "this gets set to the runTime object
  47.                                    so the component can name other
  48.                                    components and global stuff"
  49.   dad.                            "in a complex component hierarchy we
  50.                                    need to know where this component
  51.                                    is contained"
  52.   leaf.                           "TRUE - this is a basic component.
  53.                                    FALSE - this components is defined
  54.                                            in terms of other components"
  55.   type = 'circuit description'.   "just an optional comment"
  56.   pin1. pin2.                     "define some pins so this component can
  57.                                    be connected to others or controlled
  58.                                    by the user"
  59.   declare = ( ... ).              "this method initializes the pin slots
  60.                                    creating input or output pins"
  61.   u1. u2.                         "some slots to hold sub-components"
  62.   netlist = ( ... ).              "this method initializes the sub-
  63.                                    components and connects them to one
  64.                                    another and to the pins"
  65.   behave = ( ... ).               "this method sets the values of the
  66.                                    output pins as a function of the inputs"
  67.  
  68. A component object can have a netlist slot, a behave slot or both. Sending
  69. a "simulate" message to a component will create a new simulation with the
  70. component expanded ( if it has netlist ) recursively. An "exert" message
  71. does not expand the object ( if it has behave ). The exert is faster but
  72. less precise, but the two simulations should agree rather closely if the
  73. component's definitions are correct. The "askSim" message will give the
  74. user a choice of expanding components which have both netlist and behave
  75. but is not very clear about what component it is talking about.
  76.  
  77. The idea is to design circuit from the top down. Define the circuit in
  78. Self using behave and test it. When it is right you define it with netlist
  79. and "black box" subcomponents. If you get the same results as before you
  80. choose one of the subcomponents and repeat the process.
  81.  
  82. As declare, netlist and behave can have any Self expression you wish, the
  83. examples show what can be done with a little imagination.
  84.  
  85. Other objects are:
  86.   levels - 27 logic levels ( with a wide range of unknowns )
  87.   net - connects pins and resolves level conflicts
  88.   simPin - stores output levels
  89.   runTime - holds the event list and implements the simulation commands
  90.   event - holds a level to be placed on a pin in a future instant
  91.   wave - remembers level/time pairs for plotting waveforms
  92.   fsm - implements finite state machines
  93. -----------------------------------------------
  94. To use the simulator type at the prompt:
  95.  
  96. 'allSim' _RunScript
  97.  
  98. This will load the simulator if _SelfDir points to the right directory.
  99. The most basic example is a simple combinational circuit with two ORs and
  100. one AND. To start up a new simulation for this circuit type:
  101.  
  102. library cc simulate
  103.  
  104. This expands the circuit all the way down to the transistor level. You can
  105. type help to see what commands are available at this point. Before any other
  106. commands, you should type:
  107.  
  108. restart
  109.  
  110. The simulate command should probably be modified to do this automaticly but
  111. the restart can be used any time to set the simulation to it's initial state.
  112. You can save some typing by writting:
  113.  
  114. 'batch1' _RunScript
  115.  
  116. Look in the batch1.self file to see what we did. First, a few watch: commands
  117. created a list of the most interesting pins. Waves will be stored only for
  118. those pins, and only they will be listed when you type:
  119.  
  120. watch
  121.  
  122. You can see why this is useful be trying:
  123.  
  124. all
  125.  
  126. The next rest of the lines in the file are set:To: or set:To:After: to set
  127. the initial input values and to make a waveform for pin "d". To start the
  128. simulation you can type:
  129.  
  130. step
  131.  
  132. This prints the current simulation time after one step. If you try this a
  133. few more times you will see that sometimes the current time stays the same.
  134. Use "watch" to see what is happening to the circuit. "stepTo:" will only stop
  135. when the simulation time is equal to its argument. "stepBy:" used relative
  136. times to tell when to stop. Finally, "run" keeps going until there are
  137. no more event to simulate ( which might never happen in most circuits ). Try
  138. "run" to see where it all ends. You could see the results graphicly with:
  139.  
  140. draw
  141.  
  142. I don't recommend it as it draws directly on the screen. The "scale:" and
  143. "offset:" commands will change what is drawn so you can look at any level
  144. of detail you want.
  145. Try repeating the whole thing starting with:
  146.  
  147. library cc exert
  148.  
  149. The simulation will go much faster and "all" can show you why. The results
  150. are not exactly the same but are close enough.
  151.  
  152. Other examples you can try are:
  153.  
  154.     ff  - it it an example of very high speed CMOS circuits using a single
  155.           phase clock. The actual latch is "ocLatch" and ff just adds an
  156.           inverter to the output so the dynamic circuit can work. File
  157.           "batch3.self" tests the circuit to see if there are setup or
  158.           hold time problems. This can only be simulated at the transistor
  159.           level so "exert" and "askSim" will work exactly as "simulate".
  160.  
  161.     st - shows how to create a state machine. This divide by three circuit
  162.          can be tested with "batch2.self" with a simple square wave as
  163.          input.
  164.  
  165.     osc - uses a loop in netlist to connect the six inverters which are
  166.           stored in a vector. Don't try run on this one! It just shows
  167.           what you can do when Self is your circuit description language.
  168. ------------------------------------------
  169. Finally, the usual:
  170.  
  171. This software is copyrighted 1990-1993 by Jecel Mattos de Assumpcao Jr.
  172. The author grants everyone full use of all included software and files
  173. for any purpose, but is not liable for any damages of any nature that
  174. might occur as a result of the use of the software. In other words: if
  175. anything happens, it's your fault.
  176.  
  177. This will be "cleaned up" and made truly useful sometime in the next
  178. fifty years. When that happens, you can look for that release in the
  179. same place where you got this and you might just be lucky.
  180.